home *** CD-ROM | disk | FTP | other *** search
/ LiquidLibrary 2005 February / LiquidLibrary 2005 February - Disc 1.iso / pc / Portfolio Browser / Filters / PDF / LIB / gs_statd.ps < prev    next >
Text File  |  2003-01-03  |  13KB  |  356 lines

  1. %    Copyright (C) 1989, 2000 Aladdin Enterprises.  All rights reserved.
  2. % This software is licensed to a single customer by Artifex Software Inc.
  3. % under the terms of a specific OEM agreement.
  4.  
  5. % $RCSfile$ $Revision$
  6. % This file provides statusdict, serverdict, and assorted LaserWriter
  7. % operators, mostly for the benefit of poorly designed PostScript programs
  8. % that 'know' they are running on a LaserWriter.
  9.  
  10. systemdict begin
  11.     % We make statusdict a little larger for Level 2 stuff.
  12.     % Note that it must be allocated in local VM.
  13.  .currentglobal false .setglobal
  14.  /statusdict 89 dict .forcedef        % statusdict is local, sys'dict global
  15.     % To support the Level 2 job control features,
  16.     % serverdict must also be in local VM.
  17.  /serverdict 10 dict .forcedef        % serverdict is local, sys'dict global
  18.  .setglobal
  19. end
  20.  
  21. % Define various paper formats.  The Adobe documentation defines only these:
  22. % 11x17, a3, a4, a4small, b5, ledger, legal, letter, lettersmall, note.
  23. % These procedures are also accessed as data structures during initialization,
  24. % so the page dimensions must be the first two elements of the procedure.
  25.  
  26. /.setpagesize { /statusdict .systemvar begin .setpagesize end } bind def
  27. userdict begin
  28.         % Page sizes defined by Adobe documentation
  29.  /11x17 {792 1224 //.setpagesize exec} bind def  % 11x17 portrait
  30.  /a3 {842 1190 //.setpagesize exec} bind def
  31.  /a4 {595 842 //.setpagesize exec} bind def
  32. % a4small should be a4 with an ImagingBBox of [25 25 570 817].
  33.  /a4small /a4 load def
  34. % b5 see below.
  35.  /ledger {1224 792 //.setpagesize exec} bind def  % 11x17 landscape
  36.  /legal {612 1008 //.setpagesize exec} bind def
  37.  /letter {612 792 //.setpagesize exec} bind def
  38. % lettersmall should be letter with an ImagingBBox of [25 25 587 767].
  39.  /lettersmall /letter load def
  40. % note should be letter (or some other size) with the ImagingBBox
  41. % shrunk by 25 units on all 4 sides.
  42.  /note /letter load def
  43.         % End of Adobe-defined page sizes
  44. STRICT { (%END SIZES) .skipeof } if
  45.         % Other page sizes
  46.     % ISO standard paper sizes
  47.  /a0 {2380 3368 //.setpagesize exec} bind def
  48.  /a1 {1684 2380 //.setpagesize exec} bind def
  49.  /a2 {1190 1684 //.setpagesize exec} bind def
  50. % /a3 {842 1190 //.setpagesize exec} bind def    % defined by Adobe
  51. % /a4 {595 842 //.setpagesize exec} bind def    % defined by Adobe
  52.  /a5 {421 595 //.setpagesize exec} bind def
  53.  /a6 {297 421 //.setpagesize exec} bind def
  54.  /a7 {210 297 //.setpagesize exec} bind def
  55.  /a8 {148 210 //.setpagesize exec} bind def
  56.  /a9 {105 148 //.setpagesize exec} bind def
  57.  /a10 {74 105 //.setpagesize exec} bind def
  58. % ISO and JIS B sizes are different....
  59.  /isob0 {2836 4008 //.setpagesize exec} bind def
  60.  /b0 /isob0 load def
  61.  /isob1 {2004 2836 //.setpagesize exec} bind def
  62.  /b1 /isob1 load def
  63.  /isob2 {1418 2004 //.setpagesize exec} bind def
  64.  /b2 /isob2 load def
  65.  /isob3 {1002 1418 //.setpagesize exec} bind def
  66.  /b3 /isob3 load def
  67.  /isob4 {709 1002 //.setpagesize exec} bind def
  68.  /b4 /isob4 load def
  69.  /isob5 {501 709 //.setpagesize exec} bind def
  70.  /b5 /isob5 load def
  71.  /isob6 {354 501 //.setpagesize exec} bind def
  72.  /b6 /isob6 load def
  73.  /jisb0 {2916 4128 //.setpagesize exec} bind def
  74.  /jisb1 {2064 2916 //.setpagesize exec} bind def
  75.  /jisb2 {1458 2064 //.setpagesize exec} bind def
  76.  /jisb3 {1032 1458 //.setpagesize exec} bind def
  77.  /jisb4 {729 1032 //.setpagesize exec} bind def
  78.  /jisb5 {516 729 //.setpagesize exec} bind def
  79.  /jisb6 {363 516 //.setpagesize exec} bind def
  80.  /c0 {2600 3677 //.setpagesize exec} bind def
  81.  /c1 {1837 2600 //.setpagesize exec} bind def
  82.  /c2 {1298 1837 //.setpagesize exec} bind def
  83.  /c3 {918 1298 //.setpagesize exec} bind def
  84.  /c4 {649 918 //.setpagesize exec} bind def
  85.  /c5 {459 649 //.setpagesize exec} bind def
  86.  /c6 {323 459 //.setpagesize exec} bind def
  87.     % U.S. CAD standard paper sizes
  88.  /archE {2592 3456 //.setpagesize exec} bind def
  89.  /archD {1728 2592 //.setpagesize exec} bind def
  90.  /archC {1296 1728 //.setpagesize exec} bind def
  91.  /archB {864 1296 //.setpagesize exec} bind def
  92.  /archA {648 864 //.setpagesize exec} bind def
  93.     % Other paper sizes
  94.  /flsa {612 936 //.setpagesize exec} bind def  % U.S. foolscap
  95.  /flse {612 936 //.setpagesize exec} bind def  % European foolscap
  96.  /halfletter {396 612 //.setpagesize exec} bind def
  97. % /tabloid {792 1224 //.setpagesize exec} bind def  % 11x17 portrait
  98. % /csheet {1224 1584 //.setpagesize exec} bind def % ANSI C 17x22
  99. % /dsheet {1584 2448 //.setpagesize exec} bind def % ANSI D 22x34
  100. % /esheet {2448 3168 //.setpagesize exec} bind def % ANSI E 34x44
  101. %END SIZES
  102. end
  103. currentdict /.setpagesize .undef
  104.  
  105. statusdict begin
  106.  
  107. % Define the pagetype values for the known page formats.
  108. % The values for all but letter and note are arbitrary.
  109. /.pagetypenames
  110.  { /letter /note    %do not change this line, needed by 'setpagetype'
  111.    /legal /lettersmall
  112.    /11x17 /ledger
  113.    /a4small /a3 /a4
  114. STRICT { (%END SIZES) .skipeof } if
  115.    /a0 /a1 /a2 /a5 /a6 /a7 /a8 /a9 /a10
  116.    /archA /archB /archC /archD /archE
  117.    /b0 /b1 /b2 /b3 /b4 /b5 /b6
  118.    /c0 /c1 /c2 /c3 /c4 /c5 /c6
  119.    /flsa /flse /halfletter
  120.    /isob0 /isob1 /isob2 /isob3 /isob4 /isob5 /isob6
  121.    /jisb0 /jisb1 /jisb2 /jisb3 /jisb4 /jisb5 /jisb6
  122. %END SIZES
  123.  } cvlit readonly def
  124.  
  125. %%%%%% The following items were suggested by a user as useful.
  126.  
  127. % Permanent definitions
  128.  
  129. /ramsize         4194304 def
  130. /hardwareiomode        0 def
  131.     /sethardwareiomode     {pop} bind def
  132. /softwareiomode        0 def
  133.     /setsoftwareiomode     {pop} bind def
  134. /dosysstart        false def
  135.     /setdosysstart         {pop} bind def
  136. /allowjobreset      true def
  137.     /setallowjobreset      {pop} bind def
  138. /defaultpaperfamily    0 def
  139.     /setdefaultpaperfamily {pop} bind def
  140. /defaultpapertray      0 def
  141.     /setdefaultpapertray   {pop} bind def
  142. /defaulttrayswitch false def
  143.     /setdefaulttrayswitch  {pop} bind def
  144.  
  145. % Tray and format selection
  146.  
  147.  /11x17tray {/11x17 .uservar exec} bind def
  148.  /a3tray {/a3 .uservar exec} bind def
  149.  /a4tray {/a4 .uservar exec} bind def
  150.  /a5tray {/a5 .uservar exec} bind def
  151.  /a6tray {/a6 .uservar exec} bind def
  152.  /b4tray {/b4 .uservar exec} bind def
  153.  /b5tray {/b5 .uservar exec} bind def
  154.  /flsatray {/flsa .uservar exec} bind def
  155.  /flsetray {/flse .uservar exec} bind def
  156.  /halflettertray {/halfletter .uservar exec} bind def
  157.  /ledgertray {/ledger .uservar exec} bind def
  158.  /legaltray {/legal .uservar exec} bind def
  159.  /lettertray {/letter .uservar exec} bind def
  160.  
  161. % Per-job parameters
  162.  
  163. /paperfamily 0 def    % 0 is US, 1 is European
  164. /papertray 1 def
  165.     /setpapertray {statusdict exch /papertray exch put} bind def 
  166. /trayswitch false def    % paperout feeds from another tray
  167. % We don't implement the (undocumented by Adobe) papersize 'operator',
  168. % because it's very awkward to make it interact properly with all the
  169. % different ways of setting the paper size.
  170. %/papersize {/letter true} bind def    % <name of paper size>, <short-edge-first-p>
  171. /appletalktype (LaserWriter) def
  172.  
  173. %%%%%% The following items are defined in the PostScript Language
  174. %%%%%% Reference Manual, First Edition, and subsequent 'compatibility'
  175. %%%%%% documentation from Adobe.
  176.  
  177.  /checkpassword {statusdict begin .password eq end} bind def
  178.  /defaulttimeouts {statusdict begin .timeouts aload pop end} bind def
  179.  /diskonline {
  180.     false (%disk*%) { pop not exit } 100 string /IODevice resourceforall
  181.  } bind def
  182. %/dostartpage
  183.  /eescratch {pop 0} bind def
  184.  /idlefonts {statusdict begin mark .idlefonts aload pop end} bind def
  185.  /jobname () def
  186. %/jobtimeout
  187.  /manualfeed false def
  188.  /manualfeedtimeout 60 def
  189.  /margins {statusdict begin .topmargin .leftmargin end} bind def
  190.  /pagecount {4711} bind def
  191.  /pagestackorder {false} bind def
  192.  /pagetype 0 def
  193.  /prefeed false def
  194.  /printererror {pop pop} bind def
  195.  /printername {statusdict /.printername get exch copy} bind def
  196.  /processcolors /processcolors load def        % defined in systemdict
  197.  /product product def        % product is defined in systemdict
  198.  /revision revision def        % revision is defined in systemdict
  199.  /sccbatch {pop 9600 0} bind def
  200.  /sccinteractive {pop 9600 0} bind def
  201.  /setdefaulttimeouts {statusdict begin .timeouts astore pop end} bind def
  202.  /setdostartpage {statusdict exch /dostartpage exch put} bind def
  203.  /setduplexmode {mark /Duplex 3 -1 roll currentdevice putdeviceprops} bind def
  204.  /seteescratch {pop pop} bind def
  205.  /setidlefonts {] statusdict exch /.idlefonts exch put} bind def
  206.  /setjobtimeout {statusdict exch /jobtimeout exch put} bind def
  207.  /setmargins
  208.   { statusdict begin
  209.     /.leftmargin exch def /.topmargin exch def
  210.     end
  211.   } bind def
  212.  
  213. % The following compatibility operators are only documented by Adobe in a
  214. % supplement to the Red Book.
  215. %
  216. %    - pagemargin <offset>
  217. %    - pageparams <width> <height> <offset> <orientation>
  218. %    <width> <height> <orientation> setpage -
  219. %    <offset> setpagemargin -
  220. %    <width> <height> <offset> <orientation> setpageparams -
  221. %
  222. % width and height are in default units (and if orientation is odd, are
  223. % exchanged!).  offset is the x margin, also in default units.
  224. % Unfortunately, because orientation is relative to the device paper feed,
  225. % it does not have a consistent meaning in terms of image orientation.
  226. % We follow the convention that ORIENT1 determines the orientation value
  227. % that means portait: false means 0, true means 1.
  228.  
  229.  /pagemargin { 0 } bind def
  230.  /pageparams
  231.   { currentdevice 1 dict dup /.MediaSize dup put .getdeviceparams
  232.     exch pop exch pop aload pop 0 ORIENT1 { 1 } { 0 } ifelse
  233.   } bind def
  234.  /setpage
  235.   { ORIENT1 { 1 } { 0 } ifelse ne {exch} if
  236.     statusdict /.setpagesize get exec
  237.   } bind def
  238.  /setpagemargin {pop} bind def    % can't do better without setpagedevice
  239.  /setpageparams
  240.   { exch pop ORIENT1 { 1 } { 0 } ifelse ne {exch} if
  241.     statusdict /.setpagesize get exec
  242.   } bind def
  243.  /setpagetype
  244.   { statusdict begin
  245.         % The Adobe documentation only defines setpagetype
  246.         % (a Level 1 operator) as accepting the values 0 and 1,
  247.         % so we do too.
  248.       dup .pagetypenames 0 2 getinterval exch get //systemdict exch get exec
  249.       /pagetype exch def
  250.     end
  251.   } bind def
  252.  /setpassword
  253.   {exch checkpassword
  254.     {statusdict exch /.password exch put true}
  255.     {pop false}
  256.    ifelse} bind def
  257.  /setprintername
  258.   {dup length string copy statusdict exch /.printername exch put} bind def
  259.  
  260. % setresolution is not documented by Adobe, but some applications
  261. % use it anyway, without testing whether or not it is present.
  262. %
  263. %    <pixels_per_inch> setresolution -
  264. %
  265. % sets the resolution of the device.
  266.  
  267.  /setresolution
  268.   { mark /HWResolution [ 4 -1 roll dup ] currentdevice putdeviceprops pop
  269.     initmatrix erasepage
  270.   } bind def
  271.  /setsccbatch {pop pop pop} bind def
  272.  /setsccinteractive {pop pop pop} bind def
  273.  /settumble {pop} bind def
  274.  /waittimeout 300 def
  275.  
  276. %%%%%% End of documented items.
  277.  
  278. /.setpagesize
  279.  { mark /HWSize [
  280.      4 index 4 index matrix defaultmatrix dtransform
  281.      abs ceiling cvi exch abs ceiling cvi exch
  282.    ] currentdevice putdeviceprops pop pop pop
  283.    initmatrix initclip erasepage
  284.  } bind def
  285. /.password 0 def
  286. /.timeouts [0 60 30] def
  287. true setdostartpage
  288. mark setidlefonts
  289. 0 setjobtimeout
  290. 0 0 setmargins
  291. product setprintername
  292.  
  293. end    % statusdict
  294.  
  295. %%%%%% The following documented compatibility "operators" are in systemdict,
  296. %%%%%% not in statusdict.
  297.  
  298. systemdict begin
  299. .currentglobal true .setglobal
  300.  
  301. /devforall {        % <pattern> <proc> <scratch> devforall -
  302.   exch {
  303.     1 index currentdevparams
  304.     /Type .knownget { /FileSystem eq } { false } ifelse
  305.     { exec } { pop pop } ifelse
  306.   } /exec load 3 packedarray cvx exch
  307.   (*) 3 1 roll /IODevice resourceforall
  308. } odef
  309.  
  310. /devstatus {        % <(%disk*%)> devstatus <searchable> <writable>
  311.             %   <hasNames> <mounted> <removable> <searchOrder>
  312.             %   <freePages> <size> true
  313.             % <string> devstatus false
  314.   dup length 5 ge {
  315.     dup 0 5 getinterval (%disk) eq {
  316.       dup /IODevice resourcestatus {
  317.     pop pop dup currentdevparams
  318.     dup /Searchable get
  319.     exch dup /Writeable get
  320.     exch dup /HasNames get
  321.     exch dup /Mounted get
  322.     exch dup /Removable get
  323.     exch dup /SearchOrder get
  324.     exch dup /Free get
  325.     exch /LogicalSize get
  326.     9 -1 roll pop true
  327.       } {
  328.     pop false
  329.       } ifelse
  330.     } {
  331.       pop false
  332.     } ifelse
  333.   } {
  334.     pop false
  335.   } ifelse
  336. } odef
  337.  
  338. .setglobal end    % systemdict
  339.  
  340. % The following contents of serverdict are a complete guess,
  341. % based on some observed LaserWriter boilerplate.
  342.  
  343. serverdict begin
  344.  
  345.  /execjob { } bind def
  346. % The Red Book implies that something like the following is
  347. % an appropriate definition of exitserver.
  348.  /exitserver { clear stop } bind def
  349. % However, this interacts badly with our standard error handler,
  350. % so we override it with the following less appropriate definition.
  351.  /exitserver { 0 ne { clear cleardictstack } if } bind def
  352.  /setrealdevice { } bind def
  353.  
  354. end    % serverdict
  355.